<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.7"/>
<title>BrainTrain: Callbacks/DrunkenInteractionCallback.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">BrainTrain
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.7 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('_drunken_interaction_callback_8cpp_source.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">DrunkenInteractionCallback.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_drunken_interaction_callback_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="preprocessor">#include &quot;../header/DrunkenInteractionCallback.h&quot;</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;</div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;</div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="keyword">namespace </span>brtr {</div>
<div class="line"><a name="l00005"></a><span class="lineno"><a class="line" href="classbrtr_1_1_drunken_interaction_callback.html#aa252ac5f3bc393ecb75784b98e17b5a5">    5</a></span>&#160;    <a class="code" href="classbrtr_1_1_drunken_interaction_callback.html#aa252ac5f3bc393ecb75784b98e17b5a5">DrunkenInteractionCallback::DrunkenInteractionCallback</a>(osg::Node* camera,osg::Camera* hudCam, osg::Switch* geometrySwitch, <span class="keywordtype">int</span> width, <span class="keywordtype">int</span> height) :</div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;    <a class="code" href="classbrtr_1_1_base_interaction_callback.html">BaseInteractionCallback</a>(camera, hudCam, width, height),</div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;    _geometrySwitch(geometrySwitch),</div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;    _startTime(0),</div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;    _backwards(false){</div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;        <a class="code" href="classbrtr_1_1_drunken_interaction_callback.html#adaa3e659a9f6516a5b59a43813506a11">_motion</a> = <span class="keyword">new</span> osgAnimation::LinearMotion(70, 70, 70, osgAnimation::Motion::LOOP);</div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;    }</div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;</div>
<div class="line"><a name="l00013"></a><span class="lineno"><a class="line" href="classbrtr_1_1_drunken_interaction_callback.html#a86e4062f00a33768f752c1c5fa50c291">   13</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="classbrtr_1_1_drunken_interaction_callback.html#a86e4062f00a33768f752c1c5fa50c291">DrunkenInteractionCallback::interact</a>(osg::Node* node, osg::NodeVisitor* nv) {</div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;        <span class="comment">//save starttime and switch off the bottle</span></div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;        <span class="keywordflow">if</span> (<a class="code" href="classbrtr_1_1_drunken_interaction_callback.html#ab1a42a563e42cfd1d480741b30e22245">_startTime</a> == 0) {</div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;            <a class="code" href="classbrtr_1_1_drunken_interaction_callback.html#a0aa1983e0fc1cb720badb80464a8e391">_geometrySwitch</a>-&gt;setAllChildrenOff();</div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;            <a class="code" href="classbrtr_1_1_drunken_interaction_callback.html#ab1a42a563e42cfd1d480741b30e22245">_startTime</a> = nv-&gt;getFrameStamp()-&gt;getReferenceTime();</div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;        }</div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;        <span class="comment">//linear motion for the effect</span></div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;        <a class="code" href="classbrtr_1_1_drunken_interaction_callback.html#adaa3e659a9f6516a5b59a43813506a11">_motion</a>-&gt;update(1);</div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;        osg::Camera* camera = <span class="keyword">static_cast&lt;</span>osg::Camera*<span class="keyword">&gt;</span>(node);</div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;        <span class="keywordflow">if</span> (camera) {</div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;            OSG_NOTICE &lt;&lt; <span class="stringliteral">&quot;Motion Value &quot;</span> &lt;&lt; <a class="code" href="classbrtr_1_1_drunken_interaction_callback.html#adaa3e659a9f6516a5b59a43813506a11">_motion</a>-&gt;getValue() &lt;&lt; std::endl;</div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;            <span class="comment">//backwards after up to FOV 125</span></div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;            <span class="keywordflow">if</span> (<a class="code" href="classbrtr_1_1_drunken_interaction_callback.html#adaa3e659a9f6516a5b59a43813506a11">_motion</a>-&gt;getValue() &gt;= 125)</div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;                <a class="code" href="classbrtr_1_1_drunken_interaction_callback.html#a4be32ea919b41bd46acc34904fb5c7b7">_backwards</a> = !<a class="code" href="classbrtr_1_1_drunken_interaction_callback.html#a4be32ea919b41bd46acc34904fb5c7b7">_backwards</a>;</div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;            camera-&gt;setProjectionMatrixAsPerspective(<a class="code" href="classbrtr_1_1_drunken_interaction_callback.html#a4be32ea919b41bd46acc34904fb5c7b7">_backwards</a> ? 195 - <a class="code" href="classbrtr_1_1_drunken_interaction_callback.html#adaa3e659a9f6516a5b59a43813506a11">_motion</a>-&gt;getValue() : <a class="code" href="classbrtr_1_1_drunken_interaction_callback.html#adaa3e659a9f6516a5b59a43813506a11">_motion</a>-&gt;getValue(), 2, 0.01, 100000);</div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;        }<span class="comment">//camera</span></div>
<div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;        </div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;        <span class="keywordflow">if</span> (nv-&gt;getFrameStamp()-&gt;getReferenceTime() - <a class="code" href="classbrtr_1_1_drunken_interaction_callback.html#ab1a42a563e42cfd1d480741b30e22245">_startTime</a> &gt;= 20) {</div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;            <span class="keywordflow">if</span> (camera) {</div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;                camera-&gt;setProjectionMatrixAsPerspective(70, 1.778, 0.01, 100000);</div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;                <a class="code" href="classbrtr_1_1_base_interaction_callback.html#a2f36052886ec60a227e0734bfbc4bdbb">_done</a> = <span class="keyword">true</span>;</div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;                <a class="code" href="classbrtr_1_1_drunken_interaction_callback.html#a0aa1983e0fc1cb720badb80464a8e391">_geometrySwitch</a> = <span class="keyword">nullptr</span>;</div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;                <a class="code" href="classbrtr_1_1_base_interaction_callback.html#a0bca3b64724235e08740be94fe4acc8d">_hudCam</a> = <span class="keyword">nullptr</span>;</div>
<div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;                <a class="code" href="classbrtr_1_1_base_interaction_callback.html#a6666bae9f8f89ebbf75637c922ebfb54">_attachTo</a> = <span class="keyword">nullptr</span>;</div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;                <a class="code" href="classbrtr_1_1_drunken_interaction_callback.html#adaa3e659a9f6516a5b59a43813506a11">_motion</a> = <span class="keyword">nullptr</span>;</div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;                <a class="code" href="classbrtr_1_1_base_interaction_callback.html#af60dece4300b09fafe3c048397122cbd">_text</a> = <span class="keyword">nullptr</span>;</div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;                OSG_NOTICE &lt;&lt; <span class="stringliteral">&quot;DrunkenInteractionCallback: Should now be removed&quot;</span> &lt;&lt; std::endl;</div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;            }<span class="comment">//camera</span></div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;        }<span class="comment">//30 sec over</span></div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;    }</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;</div>
<div class="line"><a name="l00044"></a><span class="lineno"><a class="line" href="classbrtr_1_1_drunken_interaction_callback.html#a71b86fc410bf2965ca998eff1350cfaf">   44</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="classbrtr_1_1_drunken_interaction_callback.html#a71b86fc410bf2965ca998eff1350cfaf">DrunkenInteractionCallback::setText</a>() {</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;        <a class="code" href="classbrtr_1_1_base_interaction_callback.html#af60dece4300b09fafe3c048397122cbd">_text</a>-&gt;setText(<span class="stringliteral">&quot;Click Left Mouse for a drink!&quot;</span>);</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;    }</div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;</div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;}</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;</div>
<div class="ttc" id="classbrtr_1_1_drunken_interaction_callback_html_a4be32ea919b41bd46acc34904fb5c7b7"><div class="ttname"><a href="classbrtr_1_1_drunken_interaction_callback.html#a4be32ea919b41bd46acc34904fb5c7b7">brtr::DrunkenInteractionCallback::_backwards</a></div><div class="ttdeci">bool _backwards</div><div class="ttdef"><b>Definition:</b> <a href="_drunken_interaction_callback_8h_source.html#l00042">DrunkenInteractionCallback.h:42</a></div></div>
<div class="ttc" id="classbrtr_1_1_drunken_interaction_callback_html_a0aa1983e0fc1cb720badb80464a8e391"><div class="ttname"><a href="classbrtr_1_1_drunken_interaction_callback.html#a0aa1983e0fc1cb720badb80464a8e391">brtr::DrunkenInteractionCallback::_geometrySwitch</a></div><div class="ttdeci">osg::ref_ptr&lt; osg::Switch &gt; _geometrySwitch</div><div class="ttdef"><b>Definition:</b> <a href="_drunken_interaction_callback_8h_source.html#l00040">DrunkenInteractionCallback.h:40</a></div></div>
<div class="ttc" id="classbrtr_1_1_drunken_interaction_callback_html_a71b86fc410bf2965ca998eff1350cfaf"><div class="ttname"><a href="classbrtr_1_1_drunken_interaction_callback.html#a71b86fc410bf2965ca998eff1350cfaf">brtr::DrunkenInteractionCallback::setText</a></div><div class="ttdeci">virtual void setText()</div><div class="ttdoc">sets the text on screen. Subclasses must override to set its own (info)text </div><div class="ttdef"><b>Definition:</b> <a href="_drunken_interaction_callback_8cpp_source.html#l00044">DrunkenInteractionCallback.cpp:44</a></div></div>
<div class="ttc" id="classbrtr_1_1_base_interaction_callback_html_a6666bae9f8f89ebbf75637c922ebfb54"><div class="ttname"><a href="classbrtr_1_1_base_interaction_callback.html#a6666bae9f8f89ebbf75637c922ebfb54">brtr::BaseInteractionCallback::_attachTo</a></div><div class="ttdeci">osg::ref_ptr&lt; osg::Node &gt; _attachTo</div><div class="ttdef"><b>Definition:</b> <a href="_base_interaction_callback_8h_source.html#l00051">BaseInteractionCallback.h:51</a></div></div>
<div class="ttc" id="classbrtr_1_1_base_interaction_callback_html_a2f36052886ec60a227e0734bfbc4bdbb"><div class="ttname"><a href="classbrtr_1_1_base_interaction_callback.html#a2f36052886ec60a227e0734bfbc4bdbb">brtr::BaseInteractionCallback::_done</a></div><div class="ttdeci">bool _done</div><div class="ttdef"><b>Definition:</b> <a href="_base_interaction_callback_8h_source.html#l00053">BaseInteractionCallback.h:53</a></div></div>
<div class="ttc" id="classbrtr_1_1_base_interaction_callback_html"><div class="ttname"><a href="classbrtr_1_1_base_interaction_callback.html">brtr::BaseInteractionCallback</a></div><div class="ttdoc">This is the TemplateClass for InteractionCallbacks. </div><div class="ttdef"><b>Definition:</b> <a href="_base_interaction_callback_8h_source.html#l00024">BaseInteractionCallback.h:24</a></div></div>
<div class="ttc" id="classbrtr_1_1_drunken_interaction_callback_html_aa252ac5f3bc393ecb75784b98e17b5a5"><div class="ttname"><a href="classbrtr_1_1_drunken_interaction_callback.html#aa252ac5f3bc393ecb75784b98e17b5a5">brtr::DrunkenInteractionCallback::DrunkenInteractionCallback</a></div><div class="ttdeci">DrunkenInteractionCallback(osg::Node *camera, osg::Camera *hudCam, osg::Switch *geometrySwitch, int width, int height)</div><div class="ttdoc">Constructor. </div><div class="ttdef"><b>Definition:</b> <a href="_drunken_interaction_callback_8cpp_source.html#l00005">DrunkenInteractionCallback.cpp:5</a></div></div>
<div class="ttc" id="classbrtr_1_1_drunken_interaction_callback_html_adaa3e659a9f6516a5b59a43813506a11"><div class="ttname"><a href="classbrtr_1_1_drunken_interaction_callback.html#adaa3e659a9f6516a5b59a43813506a11">brtr::DrunkenInteractionCallback::_motion</a></div><div class="ttdeci">osg::ref_ptr&lt; osgAnimation::LinearMotion &gt; _motion</div><div class="ttdef"><b>Definition:</b> <a href="_drunken_interaction_callback_8h_source.html#l00041">DrunkenInteractionCallback.h:41</a></div></div>
<div class="ttc" id="classbrtr_1_1_drunken_interaction_callback_html_ab1a42a563e42cfd1d480741b30e22245"><div class="ttname"><a href="classbrtr_1_1_drunken_interaction_callback.html#ab1a42a563e42cfd1d480741b30e22245">brtr::DrunkenInteractionCallback::_startTime</a></div><div class="ttdeci">int _startTime</div><div class="ttdef"><b>Definition:</b> <a href="_drunken_interaction_callback_8h_source.html#l00039">DrunkenInteractionCallback.h:39</a></div></div>
<div class="ttc" id="classbrtr_1_1_drunken_interaction_callback_html_a86e4062f00a33768f752c1c5fa50c291"><div class="ttname"><a href="classbrtr_1_1_drunken_interaction_callback.html#a86e4062f00a33768f752c1c5fa50c291">brtr::DrunkenInteractionCallback::interact</a></div><div class="ttdeci">virtual void interact(osg::Node *, osg::NodeVisitor *)</div><div class="ttdoc">Drunk effect is simulated by changing the FOV of the projection matrix. </div><div class="ttdef"><b>Definition:</b> <a href="_drunken_interaction_callback_8cpp_source.html#l00013">DrunkenInteractionCallback.cpp:13</a></div></div>
<div class="ttc" id="classbrtr_1_1_base_interaction_callback_html_a0bca3b64724235e08740be94fe4acc8d"><div class="ttname"><a href="classbrtr_1_1_base_interaction_callback.html#a0bca3b64724235e08740be94fe4acc8d">brtr::BaseInteractionCallback::_hudCam</a></div><div class="ttdeci">osg::ref_ptr&lt; osg::Camera &gt; _hudCam</div><div class="ttdef"><b>Definition:</b> <a href="_base_interaction_callback_8h_source.html#l00052">BaseInteractionCallback.h:52</a></div></div>
<div class="ttc" id="classbrtr_1_1_base_interaction_callback_html_af60dece4300b09fafe3c048397122cbd"><div class="ttname"><a href="classbrtr_1_1_base_interaction_callback.html#af60dece4300b09fafe3c048397122cbd">brtr::BaseInteractionCallback::_text</a></div><div class="ttdeci">osg::ref_ptr&lt; osgText::Text &gt; _text</div><div class="ttdef"><b>Definition:</b> <a href="_base_interaction_callback_8h_source.html#l00054">BaseInteractionCallback.h:54</a></div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_2a95a2ed326e5a1065e01234384276bc.html">Callbacks</a></li><li class="navelem"><a class="el" href="_drunken_interaction_callback_8cpp.html">DrunkenInteractionCallback.cpp</a></li>
    <li class="footer">Generated on Thu Jul 17 2014 01:40:24 for BrainTrain by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.7 </li>
  </ul>
</div>
</body>
</html>
